package hero_info

import (
	"go_server/game_server/protocol/pb"
	"go_server/zinx/ziface"
	"go_server/zinx/zlog"
)

func (s *Hero_info_service) S2C_GetCells(conn ziface.IConnection, roleid int64) pb.ErrorCodeManager {
	hero := Hero_info_serviceObj.LoadByRoleId(roleid)
	if hero != nil && len(hero.RoleCells) > 0 {
		msgS2C := &pb.UpdateCellListS2C{}
		if hero.RoleCells != nil {
			msgS2C.Cells = make([]*pb.HeroCellData, 0)
			for _, cell := range hero.RoleCells {
				msgS2C.Cells = append(msgS2C.Cells, cell.To_PbData())
			}
		}
		if msgS2C != nil {
			zlog.Debugf("ProtocolManager_UpdateCellList %v", msgS2C)
			defer func() {
				conn.SendBuffPBMsg(uint32(pb.ProtocolManager_UpdateCellList), msgS2C)
			}()
		}
	}
	return pb.ErrorCodeManager_SUCCESS
}
